package com.yanggu.scala.chapater14

//计算1-50的和。使用递归完成
object RecursiveDemo01 {

  def main(args: Array[String]): Unit = {
    val now: Long = System.currentTimeMillis()
    var res = BigInt(0)
    var num = BigInt(1)
    val maxVal = BigInt(99999999L) //BigInt(99999999l)[测试效率大数]
    while (num <= maxVal) {
      res += num
      num += 1
    }
    println("res=" + res)
    println("总共耗时: " + (System.currentTimeMillis() - now) + "毫秒")
  }

}
